package net.anzhuo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsMemberMapper;
import net.anzhuo.entity.GsMember;
import net.anzhuo.service.GsMemberService;

@Service
public class GsMemberServiceImpl implements GsMemberService {

	@Autowired
	private GsMemberMapper gsMemberMapper;

	@Override
	public PaginationVO<GsMember> getListWithPage(GsMember gsMember) {
		PaginationVO<GsMember> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsMemberMapper.getListWithPage(gsMember));
		paginationVO.setTotalCount(gsMemberMapper.getCount(gsMember));
		paginationVO.setTotalPage((gsMemberMapper.getCount(gsMember) + gsMember.getPageSize() -1)  / gsMember.getPageSize());
		paginationVO.setPageNo(gsMember.getPageNo());
		return paginationVO;
	}

	@Override
	public GsMember getById(Long id) {
		return gsMemberMapper.getById(id);
	}



	@Override
	public List<GsMember> getList(GsMember gsMember) {
		return gsMemberMapper.getListByQuery(gsMember);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsMember gsMember) {
		gsMemberMapper.update(gsMember);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsMember gsMember) {
		gsMemberMapper.save(gsMember);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsMember gsMember) {
		gsMemberMapper.delete(gsMember);
	}

	@Override
	public List<GsMember> getByMd5(String md5) {
		return gsMemberMapper.getByMd5(md5);
	}

	@Override
	public void deleteByID(GsMember gsMember) {
		// TODO Auto-generated method stub
		gsMemberMapper.deleteByID(gsMember);
	}
}
